﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace myLittleC
{
    class ComExeption : Exception, IComError
    {
        public ERRORS mErrorCode{get; private set;}
        TPosition mPos;


        public ComExeption(ERRORS iErrorCode) { mErrorCode = iErrorCode;}
        public ComExeption(ERRORS iErrorCode, TPosition iPos):this(iErrorCode) {   mPos = iPos;}



        public ERRORS ErrorCode { get{ return mErrorCode; }}
        public override String ToString() { return ErrorMessage;}
        public TPosition Position { get { return mPos; } }

        public String ErrorMessage
        {
            get
            {
                String Message = "";

                switch (ErrorCode)
                {
                     case ERRORS.EOF:
                        Message = "Don't find finish of file";
                        break;
                    case ERRORS.UnknownError:
                        Message = "Unknown error";
                        break;
                    case ERRORS.InvalidConstInt:
                        Message = "Bad integer const";
                        break;
                    case ERRORS.InvalidConstFloat:
                        Message = "Bad float const";
                        break;
                    case ERRORS.InvalidConstString:
                        Message = "Bad const String";
                        break;
                    case ERRORS.InvalidEscSeq:
                        Message = "Bad Esc Sting";
                        break;
                    case ERRORS.BadExpression:
                        Message = "Bad Expression";
                        break;
                    case ERRORS.BadUnaryExp:
                        Message = "Bad Unary Expression";
                        break;
                    case ERRORS.UnExpRightParan:
                        Message = "Don't find )";
                        break;
                    case ERRORS.BadLValue:
                        Message = "l-value must be variable";
                        break;
                    case ERRORS.BadDeclaration:
                        Message = "Bad Declaration";
                        break;
                    case ERRORS.DublDeclaration:
                        Message = "Item With This Name had Defined";
                        break;
                    case ERRORS.NotDefType:
                        Message = "Don't Define Type";
                        break;
                    default:
                        Message = "Don't define Error";
                        break;
                }
                return String.Format("ERROR: {0}, in {1}", Message, Position);
            }
        }

        class ParseException : Exception
        {
            public ERRORS ErrorCode { get; private set; }

            public String ErrorMessage()
            {
                return "";
            }

            
            public override String ToString() { return ErrorMessage(); }
        }
    }
}
